<?php

namespace app\controller;

use app\service\OverviewService;
use support\Request;
use support\Response;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

/**
 * 概览
 */
class OverviewController
{
    /**
     * @var OverviewService
     */
    private $overviewService;

    public function __construct()
    {
        $this->overviewService = OverviewService::getInstance();
    }

    /**
     * 概览统计
     * @param Request $request
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function statistics(Request $request): Response
    {
        $res = $this->overviewService->statistics($request->getTenantId());
        return json(success_response('', $res));
    }
}